package contest.co6136;

import java.util.HashSet;
import java.util.Set;

public class Solution {
    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set=new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        int res=0;

        for (int i = 0; i < nums.length-2; i++) {
            if (set.contains(nums[i]+diff)&&set.contains(nums[i]+2*diff)){
                res++;
            }
        }
        return res;
    }
}
